#include "MemoryPCH.h"

#include "MM_MemoryTbbAllocPolicy.h"

using namespace Memory;
//----------------------------------------------------------------------------
//MM_MemoryTbbAllocPolicy
//----------------------------------------------------------------------------
void* MM_MemoryTbbAllocPolicy::allocBytes(size_t count)
{
	void* ptr = scalable_malloc(count);

	return ptr;
}
//---------------------------------------------------------------------
void* MM_MemoryTbbAllocPolicy::allocBytesAligned(size_t count,size_t align)
{
	// default to platform SIMD alignment if none specified
	void* ptr =  scalable_aligned_malloc(count,align);

	return ptr;
}
//---------------------------------------------------------------------
void* MM_MemoryTbbAllocPolicy::reallocBytes(void* ptr ,size_t count)
{
	void* newPtr = scalable_realloc( ptr , count );

	return newPtr;
}
//---------------------------------------------------------------------
void* MM_MemoryTbbAllocPolicy::reallocBytesAligned(void* ptr , size_t count ,size_t align)
{
	void* newPtr = scalable_aligned_realloc( ptr , count ,align);

	return newPtr;
}
//---------------------------------------------------------------------
void MM_MemoryTbbAllocPolicy::deallocBytes(void* ptr)
{
	// deal with null
	if (!ptr)
		return;

	scalable_free(ptr);
}
//---------------------------------------------------------------------
void MM_MemoryTbbAllocPolicy::deallocBytesAligned(void* ptr,size_t align)
{
	// deal with null
	if (!ptr)
		return;

	scalable_aligned_free(ptr);
}
